package com.newland.starpos.partner.configuration;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Created by liuNW on 2018/9/27.
 */
@Configuration
@EnableTransactionManagement
@MapperScan("com.newland.starpos.partner.mapper")
public class MybatisPlusConfiguration {

    @Bean   //分页
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor page = new PaginationInterceptor();
        return page;
    }

    @Bean
    @Profile("dev")// 性能分析,只在开发阶段开启,不可在生产环境使用
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor perfor = new PerformanceInterceptor();
        perfor.setFormat(false);//sql格式化
        perfor.setMaxTime(100); //最大100ms,超过优化
        return perfor;
    }

}
